<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="http://www.wanrenhui.com" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	  <%@include file="/res/include/base-head.jsp"%>
	  <%@include file="/res/include/jquery-easyui.jsp"%>
	<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/order/orderBase.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/mall/mallOrder.js"></script>
  </head>
  <body>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'north',border:false,split:false">
	    	<form id="query-form" class="search_form clearfix">
	            <dl>
					<dt>订单号：</dt>
					<dd>
						<input name="orderNo" id="orderNo" type="text" class="txt" maxlength="64"/>
					</dd>
				</dl>
				<dl>
					<dt>用户呢称：</dt>
					<dd>
						<input name="buyerNick" id="buyerNick" type="text" class="txt" maxlength="64"/>
					</dd>
				</dl>
				<dl>
					<dt>店铺名称：</dt>
					<dd>
						<input name="shopName" id="shopName" type="text" class="txt" maxlength="64"/>
					</dd>
				</dl>
				<p class="cl"></p>
				<dl>
	                <dt>业务类型：</dt>
	                <dd>
	                	<select name="orderType" id="orderType" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                		<option value="1">家政</option>
	                		<option value="2">商城</option>
	                		<option value="3">闲置品</option>
	                		<option value="4">活动</option>
	                		<option value="5">代收代送</option>
	                		<option value="6">圈商</option>
	                	</select>
	                </dd>
	            </dl>
	            <dl>
	                <dt>订单状态：</dt>
	                <dd>
	                	<select name="orderStatus" id="orderStatus" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                		<option value="1">未完成</option>
	                		<option value="2">已完成</option>
	                		<option value="3">已取消</option>
	                		<option value="4">已删除</option>
	                	</select>
	                </dd>
	            </dl>
	            <dl>
	                <dt>支付状态：</dt>
	                <dd>
	                	<select name="payStatus" id="payStatus" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                		<option value="1">未付款</option>
	                		<option value="2">已付款</option>
	                	</select>
	                </dd>
	            </dl>
	            <dl>
	                <dt>收发货状态：</dt>
	                <dd>
	                	<select name="deliveryStatus" id="deliveryStatus" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                		<option value="1">未发货</option>
	                		<option value="2">商家已发货</option>
	                		<option value="3">已签收</option>
	                		
	                	</select>
	                </dd>
	            </dl>
	            <dl>
	                <dt>退款状态：</dt>
	                <dd>
	                	<select name="returnPayStatus" id="returnPayStatus" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                		<option value="1">不需要退款</option>
	                		<option value="2">申请退款</option>
	                		<option value="3">退款完成</option>
	                		<option value="4">拒绝退款</option>
	                	</select>
	                </dd>
	            </dl>
	            <p class="cl"></p>
	            <dl>
	            	<dt>下单时间：从</dt>
	                <dd>
		                <input name="startAtStr" id="startAtStr" type="text" class="txt easyui-datetimebox" maxlength="19"/> 到 
		                <input name="endAtStr" id="endAtStr" type="text" class="txt easyui-datetimebox" maxlength="19"/>
	                </dd>
	            </dl>
	            <dl>
	            	<dt>订单状态时间：从</dt>
	                <dd>
		                <input name="startOrderStatusAtStr" id="startOrderStatusAtStr" type="text" class="txt easyui-datetimebox" maxlength="19"/> 到 
		                <input name="endOrderStatusAtStr" id="endOrderStatusAtStr" type="text" class="txt easyui-datetimebox" maxlength="19"/>
	                </dd>
	            </dl>
	            <p class="search_form_btn">
	            	<input type="button" value="搜索" class="icon_serach" onclick="admin.orderBase.query()" />
	            </p>
	            <dl></dl>
	            <p class="search_form_btn">
	            	<input type="button" value="导出excel" class="icon_serach" onclick="admin.orderBase.export2Excel()" />
	            </p>
	        </form>
	  	</div>
	    <div data-options="region:'center',border:false">
		    <table id="datagrid" data-options="url:'${pageContext.request.contextPath}/order/base/list',toolbar:'#toolbar'">
				<thead>
					<tr>
					    <th data-options="field:'id',align:'center',width:220,formatter:formatOperation">操作</th>
						<th data-options="field:'orderNo',width:150,align:'center'">订单号</th>
						<th data-options="field:'title',width:200,align:'center'">订单名称</th>
						<th data-options="field:'communityName',width:200,align:'center'">社区名称</th>
						<th data-options="field:'orderType',width:80,align:'center',formatter:formatOrderType">业务类型</th>
						<th data-options="field:'buyerNick',width:80,align:'center'">买方</th>
						<th data-options="field:'sellerNick',width:80,align:'center'">卖方</th>
						<th data-options="field:'shopName',width:80,align:'center'">店铺名称</th>
						<th data-options="field:'originalTotal',width:80,align:'center'">订单原价</th>
						<th data-options="field:'sellerTotal',width:110,align:'center'">卖家收入</th>
						<th data-options="field:'couponPay',width:80,align:'center'">优惠券支付</th>
						<th data-options="field:'salesQuanStr',width:80,align:'center'">圈圈满减</th>
						<th data-options="field:'salesShopStr',width:80,align:'center'">商家满减</th>
						<th data-options="field:'cashPay',width:80,align:'center'">余额支付</th>
						<th data-options="field:'quanPay',width:80,align:'center'">圈币支付</th>
						<th data-options="field:'aliPay',width:80,align:'center'">支付宝支付</th>
						<th data-options="field:'weixinPay',width:80,align:'center'">微信支付</th>
						<th data-options="field:'strNewAt',width:140,align:'center'">下单时间</th>
						<th data-options="field:'strOrderStatusAt',width:140,align:'center'">订单状态时间</th>
						<th data-options="field:'orderStatus',width:70,align:'center',formatter:formatOrderStatus">订单状态</th>
						<th data-options="field:'payStatus',width:70,align:'center',formatter:formatPayStatus">支付状态</th>
						<th data-options="field:'deliveryStatus',width:90,align:'center',formatter:formatDeliveryStatus">收发货状态</th>
						<th data-options="field:'deliveryStatusSignType',width:80,align:'center',formatter:formatDeliveryStatusSignType">签收类型</th>
						<th data-options="field:'returnPayStatus',width:80,align:'center',formatter:formatReturnPayStatus">退款状态</th>
					</tr>
				</thead>
			</table>
	  	</div>
	</div>

	<script>
	
		function formatDeliveryStatusSignType(value,row,index) {
			//收发货状态的签收类型:1-买家手动签收;2-逾期自动签收;3-配送人签收;4-买家自提签收
			var l_html = '-';
			if (value==1) {
				l_html = '买家签收';
			} else if (value==2) {
				l_html = '自动签收';
			}else if (value==3) {
				l_html = '配送人签收';
			}else if (value==4) {
				l_html = '买家自提签收';
			}
			return l_html;
		}
		function formatDeliveryStatus(value,row,index) {
			//收发货状态DeliveryStatusEnum:1-未发货;2-商家已发货;3-已签收'
			var l_html = '';
			if (value==1) {
				l_html = '未发货';
			} else if (value==2) {
				l_html = '商家已发货';
			}else if (value==3) {
				l_html = '已签收';
			}
			return l_html;
		}
		function formatReturnPayStatus(value,row,index) {
			var l_html = '-';
			if (value==2) {
				l_html = '申请退款';
			} else if (value==3) {
				l_html = '退款完成';
			} else if (value==4) {
				l_html = '拒绝退款';
			}
			return l_html;
		}
		function formatOrderType(value,row,index) {
			var l_html = '家政';
			if (value==2) {
				l_html = '商城';
			} else if (value==3) {
				l_html = '闲置品';
			}else if (value==4) {
				l_html = '活动';
			}else if (value==5) {
				l_html = '代收代送';
			}else if (value==6) {
				l_html = '圈商';
			}
			
			return l_html;
		}
		function formatOrderStatus(value,row,index) {
			var l_html = '未完成';
			if (value==2) {
				l_html = '已完成';
			} else if (value==3) {
				l_html = '已取消';
			} else if (value==4) {
				l_html = '已删除';
			}
			return l_html;
		}
		function formatPayStatus(value,row,index) {
			var l_html = '未付款';
			if (value==2) {
				l_html = '已付款';
			}
			return l_html;
		}
		function formatOperation(value,row,index) {
			var l_html = '';
			l_html += '<a href="javascript:;" class="table_link" onclick="admin.orderBase.detail('+row.id+')">查看</a>';
			if(row.orderStatus == 1 && row.payStatus == 1){//未付款订单
				l_html += '<a href="javascript:;" class="table_link" onclick="admin.orderBase.cancel('+row.id+')">取消订单</a>';
			}
			if(row.returnPayStatus == 2){
				l_html += '<a href="javascript:;" class="table_link" onclick="admin.orderBase.agreeReturnPay('+row.id+')">同意退款</a>';
				l_html += '|<a href="javascript:;" class="table_link" onclick="admin.orderBase.refuseReturnPay('+row.id+')">拒绝退款</a>';
			}
			if (row.payStatus == 2 && row.deliveryStatus == 1 
					&& row.returnPayStatus != 2 && row.returnPayStatus != 3) { //已付款 且未发货且非申请退款且非退款完成
				if(row.orderType == 2){//商城发货
					l_html += '|<a href="javascript:;" class="table_link" onclick="admin.mallOrder.toSend('+row.id+')">发货</a>';
				}else if(row.orderType == 6){//圈商-便利店发货
					l_html += '|<a href="javascript:;" class="table_link" onclick="admin.mallOrder.qqStoreSend('+row.orderNo+','+row.shopId+')">发货</a>';
				}
			}
			return l_html;
		}
	</script>
  </body>
</html>
